import 'package:flutter/material.dart';
import 'CountBLoC.dart';
import 'BLoCTwo.dart';

class BLoCOne extends StatefulWidget {
  @override
  _BLoCOneState createState() => _BLoCOneState();
}

class _BLoCOneState extends State<BLoCOne> {
  @override
  Widget build(BuildContext context) {
    return StreamBuilder<int>(
      stream: bLoC.stream,
      initialData: bLoC.value,
      builder: (BuildContext context, AsyncSnapshot<int> snapshot) {
        return Scaffold(
          appBar: AppBar(
            title: Text("BLoC测试首页"),
          ),
          body: Center(
            child: Text(
              snapshot.data.toString(),
              style: TextStyle(fontSize: 30, color: Colors.red[600]),
            ),
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: () {
              Navigator.push(
                  context, MaterialPageRoute(builder: (context) => BLoCTwo()));
            },
            child: Icon(Icons.call_missed_outgoing),
            tooltip: "下一页",
          ),
        );
      },
    );
  }
}
